let arr = [1, 2, 3, 4, 5]
let arr1 = [2, 3, 4, 5, 6]
// let newArr = arr.map((item) => {
//   return item * 2
// }, arr1)
// console.log(newArr);

Array.prototype.myMap = function (fn, thisArg) {
  let arr = []
  let thisV = thisArg || null
  this.reduce((total, currentValue, i, thisArr) => {
    arr.push(fn.call(thisV, currentValue, i, thisArr))
  }, null)
  return arr
}
let newArr2 = arr.myMap((item) => {
  return item * 2
}, arr1)
// console.log(newArr2);
Array.prototype.myMap = function (fn) {
  let result = []
  this.reduce((total, current, i) => {
    result.push(fn(current, i))
  }, null)
  return result
}
let arr2 = arr.myMap((item) => item * 2)
console.log(arr2);